﻿<?xml version="1.0" encoding="UTF-8"?>
<!--=============================================================
    File: LeftNav.xslt                                                   
    Created by: sitecore\admin                                       
    Created: 7/26/2010 10:56:13 AM                                               
    Copyright notice at bottom of file
==============================================================-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sc="http://www.sitecore.net/sc" xmlns:dot="http://www.sitecore.net/dot" exclude-result-prefixes="dot sc">
  <!-- output directives -->
  <xsl:output method="html" indent="no" encoding="UTF-8" />
  <!-- parameters -->
  <xsl:param name="lang" select="'en'" />
  <xsl:param name="id" select="''" />
  <xsl:param name="sc_item" />
  <xsl:param name="sc_currentitem" />
  <!-- variables -->
  <!-- Uncomment one of the following lines if you need a "home" variable in you code -->
  <xsl:variable name="home" select="sc:item('/sitecore/content/EFI/',.)" />
  <!--<xsl:variable name="home" select="/*/item[@key='content']/item[@key='home']" />-->
  <!--<xsl:variable name="home" select="$sc_currentitem/ancestor-or-self::item[@template='Vutek Landing']" />-->
  <!-- entry point -->
  <xsl:template match="*">
    <xsl:apply-templates select="$sc_item" mode="main" />

  </xsl:template>
  <!--==============================================================-->
  <!-- main                                                         -->
  <!--==============================================================-->
  <xsl:template match="*" mode="main">
    <xsl:for-each select="$home/item">
      <xsl:if test="$sc_currentitem/ancestor-or-self::item/@id = @id">
        <h3>
          <sc:text field="Navigation Title"/>
        </h3>
      </xsl:if>
    </xsl:for-each>
    <ul class="nav">
      <xsl:for-each select="$home/item">
        <xsl:if test="sc:fld('Dont Show In Left Nav',.) = ''">
          <!-- First level -->
          <xsl:element name="li">
            <xsl:attribute name="class">
              <xsl:if test="./item">hasChildren </xsl:if>
              <xsl:if test="$sc_currentitem/self::item/@id = @id">selected </xsl:if>
              <xsl:if test="$sc_currentitem/ancestor-or-self::item/@id = @id">open </xsl:if>
              <xsl:if test="sc:fld('Navigation Title',.) = sc:fld('Page Title',$sc_currentitem)">selected </xsl:if>
              <xsl:if test="position() = last()">last</xsl:if>
            </xsl:attribute>
            <xsl:choose>
              <xsl:when test="sc:fld('Link to Different Page',.)!=''">
                <sc:link field="Link to Different Page">
                  <span>
                    <xsl:choose>
                      <xsl:when test="sc:fld('Left Navigation Title',.)!=''">
                        <sc:text field="Left Navigation Title"/>
                      </xsl:when>
                      <xsl:otherwise>
                        <xsl:choose>
                          <xsl:when test="sc:fld('Navigation Title',.)!=''">
                            <sc:text field="Navigation Title" />
                          </xsl:when>
                          <xsl:otherwise>
                            <xsl:choose>
                              <xsl:when test="sc:fld('Nav Title',.)!=''">
                                <sc:text field="Nav Title" />
                              </xsl:when>
                              <xsl:otherwise>
                                <xsl:choose>
                                  <xsl:when test="sc:fld('NavTitle',.)!=''">
                                    <sc:text field="NavTitle" />
                                  </xsl:when>
                                  <xsl:otherwise>
                                    <xsl:value-of select="./@name" />
                                  </xsl:otherwise>
                                </xsl:choose>
                              </xsl:otherwise>
                            </xsl:choose>
                          </xsl:otherwise>
                        </xsl:choose>
                      </xsl:otherwise>
                    </xsl:choose>
                  </span>
                </sc:link>
              </xsl:when>
              <xsl:otherwise>
                <sc:link>
                  <span>
                    <xsl:choose>
                      <xsl:when test="sc:fld('Left Navigation Title',.)!=''">
                        <sc:text field="Left Navigation Title"/>
                      </xsl:when>
                      <xsl:otherwise>
                        <xsl:choose>
                          <xsl:when test="sc:fld('Navigation Title',.)!=''">
                            <sc:text field="Navigation Title" />
                          </xsl:when>
                          <xsl:otherwise>
                            <xsl:choose>
                              <xsl:when test="sc:fld('Nav Title',.)!=''">
                                <sc:text field="Nav Title" />
                              </xsl:when>
                              <xsl:otherwise>
                                <xsl:choose>
                                  <xsl:when test="sc:fld('NavTitle',.)!=''">
                                    <sc:text field="NavTitle" />
                                  </xsl:when>
                                  <xsl:otherwise>
                                    <xsl:value-of select="./@name" />
                                  </xsl:otherwise>
                                </xsl:choose>
                              </xsl:otherwise>
                            </xsl:choose>
                          </xsl:otherwise>
                        </xsl:choose>
                      </xsl:otherwise>
                    </xsl:choose>
                  </span>
                </sc:link>
              </xsl:otherwise>
            </xsl:choose>
            <xsl:if test="./item">
              <ul>
                <xsl:for-each select="./item">
                  <!-- Second Level -->
                  <xsl:if test="sc:fld('Dont Show in Left Nav',.)='' or (sc:fld('Dont Show in Nav',.)='' and sc:fld('Show in LeftNav',.)!='')">
                    <!--<xsl:if test="sc:fld('Show All Siblings',$sc_currentitem)!='' and $sc_currentitem/self::item/@id != @id">wooinvi </xsl:if>-->
                    <!-- Begin Doan code quan trong-->
                    <xsl:if test="(sc:fld('Show All Siblings',$sc_currentitem) !=''
                           and $sc_currentitem/child::item/@id = @id
                            or $sc_currentitem/ancestor-or-self::item/@id = @id)">
                      <!--<xsl:if test="(sc:fld('Show All Siblings',$sc_currentitem) !='' or $sc_currentitem/self::item/@id = @id)">-->
                      <!-- End Doan code quan trong-->
                      <!--1-->
                      <xsl:element name="li">
                        <xsl:attribute name="class">
                          <xsl:if test="./item">hasChildren </xsl:if>
                          <xsl:if test="$sc_currentitem/self::item/@id = @id">selected </xsl:if>
                          <!-- Begin Doan code quan trong-->
                          <xsl:if test="$sc_currentitem/ancestor-or-self::item/@id = @id  and sc:fld('Show All Children',.)!=''">open </xsl:if>
                          <!-- End Doan code quan trong-->
                          <xsl:if test="position() = last()">last</xsl:if>
                        </xsl:attribute>
                        <xsl:choose>
                          <xsl:when test="sc:fld('Link to Different Page',.)!=''">
                            <sc:link field="Link to Different Page">
                              <span>
                                <xsl:choose>
                                  <xsl:when test="sc:fld('Left Navigation Title',.)!=''">
                                    <sc:text field="Left Navigation Title"/>
                                  </xsl:when>
                                  <xsl:otherwise>
                                    <xsl:choose>
                                      <xsl:when test="sc:fld('Navigation Title',.)!=''">
                                        <sc:text field="Navigation Title" />
                                      </xsl:when>
                                      <xsl:otherwise>
                                        <xsl:choose>
                                          <xsl:when test="sc:fld('Nav Title',.)!=''">
                                            <sc:text field="Nav Title" />
                                          </xsl:when>
                                          <xsl:otherwise>
                                            <xsl:choose>
                                              <xsl:when test="sc:fld('NavTitle',.)!=''">
                                                <sc:text field="NavTitle" />
                                              </xsl:when>
                                              <xsl:otherwise>
                                                <xsl:value-of select="./@name" />
                                              </xsl:otherwise>
                                            </xsl:choose>
                                          </xsl:otherwise>
                                        </xsl:choose>
                                      </xsl:otherwise>
                                    </xsl:choose>
                                  </xsl:otherwise>
                                </xsl:choose>
                              </span>
                            </sc:link>
                          </xsl:when>
                          <xsl:when test="sc:fld('HomeURL',.)!=''">
                            <xsl:element name="a">
                              <xsl:attribute name="href">
                                <sc:text field="HomeURL"/>
                              </xsl:attribute>
                              <span>
                                <sc:text field="Page Title"/>
                                <sc:text field="PageTitle"/>
                              </span>
                            </xsl:element>
                          </xsl:when>
                          <xsl:otherwise>
                            <sc:link>
                              <span>
                                <xsl:choose>
                                  <xsl:when test="sc:fld('Left Navigation Title',.)!=''">
                                    <sc:text field="Left Navigation Title"/>
                                  </xsl:when>
                                  <xsl:otherwise>
                                    <xsl:choose>
                                      <xsl:when test="sc:fld('Navigation Title',.)!=''">
                                        <sc:text field="Navigation Title" />
                                      </xsl:when>
                                      <xsl:otherwise>
                                        <xsl:choose>
                                          <xsl:when test="sc:fld('Nav Title',.)!=''">
                                            <sc:text field="Nav Title" />
                                          </xsl:when>
                                          <xsl:otherwise>
                                            <xsl:choose>
                                              <xsl:when test="sc:fld('NavTitle',.)!=''">
                                                <sc:text field="NavTitle" />
                                              </xsl:when>
                                              <xsl:otherwise>
                                                <xsl:value-of select="./@name" />
                                              </xsl:otherwise>
                                            </xsl:choose>
                                          </xsl:otherwise>
                                        </xsl:choose>
                                      </xsl:otherwise>
                                    </xsl:choose>
                                  </xsl:otherwise>
                                </xsl:choose>
                              </span>
                            </sc:link>
                          </xsl:otherwise>
                        </xsl:choose>
                        <xsl:if test="./item">
                          <ul>
                            <xsl:for-each select="./item">
                              <!-- Third Level -->
                              <!--<xsl:value-of select="sc:fld('Show All Children',..)"/>-->
                              <!--<xsl:if test="$sc_currentitem/ancestor::item/@id = item/@parentid">wooinvi</xsl:if>-->
                              <xsl:if test="sc:fld('Dont Show in Left Nav',.)='' or (sc:fld('Dont Show in Nav',.)='' and sc:fld('Show in LeftNav',.)!='')">
                                <xsl:if test="(sc:fld('Show All Siblings',$sc_currentitem/ancestor-or-self::item) ='' 
                                              or sc:fld('Show All Siblings',$sc_currentitem) !='' 
                                              or $sc_currentitem/ancestor-or-self::item/@id = @id)">
                                  <xsl:element name="li">
                                    <xsl:attribute name="class">
                                      <xsl:if test="./item">hasChildren </xsl:if>
                                      <xsl:if test="$sc_currentitem/self::item/@id = @id">selected </xsl:if>
                                      <xsl:if test="$sc_currentitem/ancestor-or-self::item/@id = @id  and sc:fld('Show All Children',.)!=''">open </xsl:if>
                                      <xsl:if test="$sc_currentitem/following-sibling::item/@id = @id and  sc:fld('Show All Siblings',$sc_currentitem) ='' ">closeSubItem </xsl:if>
                                      <xsl:if test="$sc_currentitem/preceding-sibling::item/@id = @id and  sc:fld('Show All Siblings',$sc_currentitem) ='' ">closeSubItem </xsl:if>

                                      <xsl:if test="position() = last()">last </xsl:if>
                                    </xsl:attribute>
                                    
                                    <xsl:choose>
                                      <xsl:when test="sc:fld('Link to Different Page',.)!=''">
                                        <sc:link field="Link to Different Page">
                                          <span>
                                            <xsl:choose>
                                              <xsl:when test="sc:fld('Left Navigation Title',.)!=''">
                                                > <sc:text field="Left Navigation Title"/>
                                              </xsl:when>
                                              <xsl:otherwise>
                                                <xsl:choose>
                                                  <xsl:when test="sc:fld('Navigation Title',.)!=''">
                                                    > <sc:text field="Navigation Title" />
                                                  </xsl:when>
                                                  <xsl:otherwise>
                                                    <xsl:choose>
                                                      <xsl:when test="sc:fld('Nav Title',.)!=''">
                                                        > <sc:text field="Nav Title" />
                                                      </xsl:when>
                                                      <xsl:otherwise>
                                                        <xsl:choose>
                                                          <xsl:when test="sc:fld('NavTitle',.)!=''">
                                                            > <sc:text field="NavTitle" />
                                                          </xsl:when>
                                                          <xsl:otherwise>
                                                            > <xsl:value-of select="./@name" />
                                                          </xsl:otherwise>
                                                        </xsl:choose>
                                                      </xsl:otherwise>
                                                    </xsl:choose>
                                                  </xsl:otherwise>
                                                </xsl:choose>
                                              </xsl:otherwise>
                                            </xsl:choose>
                                          </span>
                                        </sc:link>
                                      </xsl:when>
                                      <xsl:when test="sc:fld('HomeURL',.)!=''">
                                        <xsl:element name="a">
                                          <xsl:attribute name="href">
                                            <sc:text field="HomeURL"/>
                                          </xsl:attribute>
                                          <span>
                                            > <sc:text field="NavTitle"/>
                                          </span>
                                        </xsl:element>
                                      </xsl:when>
                                      <xsl:otherwise>
                                        <sc:link>
                                          <span>
                                            <xsl:choose>
                                              <xsl:when test="sc:fld('Left Navigation Title',.)!=''">
                                                > <sc:text field="Left Navigation Title"/>
                                              </xsl:when>
                                              <xsl:otherwise>
                                                <xsl:choose>
                                                  <xsl:when test="sc:fld('Navigation Title',.)!=''">
                                                    > <sc:text field="Navigation Title" />
                                                  </xsl:when>
                                                  <xsl:otherwise>
                                                    <xsl:choose>
                                                      <xsl:when test="sc:fld('Nav Title',.)!=''">
                                                        > <sc:text field="Nav Title" />
                                                      </xsl:when>
                                                      <xsl:otherwise>
                                                        <xsl:choose>
                                                          <xsl:when test="sc:fld('NavTitle',.)!=''">
                                                            > <sc:text field="NavTitle" />
                                                          </xsl:when>
                                                          <xsl:otherwise>
                                                            > <xsl:value-of select="./@name" />
                                                          </xsl:otherwise>
                                                        </xsl:choose>
                                                      </xsl:otherwise>
                                                    </xsl:choose>
                                                  </xsl:otherwise>
                                                </xsl:choose>
                                              </xsl:otherwise>
                                            </xsl:choose>
                                          </span>
                                        </sc:link>
                                      </xsl:otherwise>
                                    </xsl:choose>



                                    <!-- level 4-->

                                    <xsl:if test="./item">
                                      <ul style="border: solid 1px #5a1c46;">
                                        <xsl:for-each select="./item">
                                          <!-- 4 Level -->
                                          <!--<xsl:value-of select="sc:fld('Show All Children',..)"/>-->
                                          <!--<xsl:if test="$sc_currentitem/ancestor::item/@id = item/@parentid">wooinvi</xsl:if>-->
                                          <xsl:if test="sc:fld('Dont Show in Left Nav',.)='' or (sc:fld('Dont Show in Nav',.)='' and sc:fld('Show in LeftNav',.)!='')">
                                            <xsl:if test="(sc:fld('Show All Siblings',$sc_currentitem/ancestor-or-self::item) ='' 
                                              or sc:fld('Show All Siblings',$sc_currentitem) !='' 
                                              or $sc_currentitem/ancestor-or-self::item/@id = @id)">
                                              <xsl:element name="li">
                                                <xsl:attribute name="class">
                                                  <xsl:if test="../item">hasChildren </xsl:if>
                                                  <xsl:if test="$sc_currentitem/self::item/@id = @id">selected </xsl:if>
                                                  <xsl:if test="$sc_currentitem/ancestor-or-self::item/@id = @id  and sc:fld('Show All Children',.)!=''">open </xsl:if>

                                                  <xsl:if test="$sc_currentitem/parent/parent::item/@id = @id  and sc:fld('Show All Children',$sc_currentitem/parent)!=''">open </xsl:if>
                                                  <!--<xsl:if test="position() = last()">last </xsl:if>-->
                                                  <!--<xsl:if test="$sc_currentitem/following-sibling::item/@id = @id and  sc:fld('Show All Siblings',$sc_currentitem) ='' ">closeSubItem </xsl:if>
                                                  <xsl:if test="$sc_currentitem/preceding-sibling::item/@id = @id and  sc:fld('Show All Siblings',$sc_currentitem) ='' ">closeSubItem </xsl:if>-->


                                                </xsl:attribute>
                                                <xsl:choose>
                                                  <xsl:when test="sc:fld('Link to Different Page',.)!=''">
                                                    <sc:link field="Link to Different Page">
                                                      <span>
                                                        <xsl:choose>
                                                          <xsl:when test="sc:fld('Left Navigation Title',.)!=''">
                                                            > <sc:text field="Left Navigation Title"/>
                                                          </xsl:when>
                                                          <xsl:otherwise>
                                                            <xsl:choose>
                                                              <xsl:when test="sc:fld('Navigation Title',.)!=''">
                                                                > <sc:text field="Navigation Title" />
                                                              </xsl:when>
                                                              <xsl:otherwise>
                                                                <xsl:choose>
                                                                  <xsl:when test="sc:fld('Nav Title',.)!=''">
                                                                    > <sc:text field="Nav Title" />
                                                                  </xsl:when>
                                                                  <xsl:otherwise>
                                                                    <xsl:choose>
                                                                      <xsl:when test="sc:fld('NavTitle',.)!=''">
                                                                        > <sc:text field="NavTitle" />
                                                                      </xsl:when>
                                                                      <xsl:otherwise>
                                                                        > <xsl:value-of select="./@name" />
                                                                      </xsl:otherwise>
                                                                    </xsl:choose>
                                                                  </xsl:otherwise>
                                                                </xsl:choose>
                                                              </xsl:otherwise>
                                                            </xsl:choose>
                                                          </xsl:otherwise>
                                                        </xsl:choose>
                                                      </span>
                                                    </sc:link>
                                                  </xsl:when>
                                                  <xsl:when test="sc:fld('HomeURL',.)!=''">
                                                    <xsl:element name="a">
                                                      <xsl:attribute name="href">
                                                        <sc:text field="HomeURL"/>
                                                      </xsl:attribute>
                                                      <span>
                                                        > <sc:text field="NavTitle"/>
                                                      </span>
                                                    </xsl:element>
                                                  </xsl:when>
                                                  <xsl:otherwise>
                                                    <sc:link>
                                                      <span>
                                                        <xsl:choose>
                                                          <xsl:when test="sc:fld('Left Navigation Title',.)!=''">
                                                            > <sc:text field="Left Navigation Title"/>
                                                          </xsl:when>
                                                          <xsl:otherwise>
                                                            <xsl:choose>
                                                              <xsl:when test="sc:fld('Navigation Title',.)!=''">
                                                                > <sc:text field="Navigation Title" />
                                                              </xsl:when>
                                                              <xsl:otherwise>
                                                                <xsl:choose>
                                                                  <xsl:when test="sc:fld('Nav Title',.)!=''">
                                                                    > <sc:text field="Nav Title" />
                                                                  </xsl:when>
                                                                  <xsl:otherwise>
                                                                    <xsl:choose>
                                                                      <xsl:when test="sc:fld('NavTitle',.)!=''">
                                                                        > <sc:text field="NavTitle" />
                                                                      </xsl:when>
                                                                      <xsl:otherwise>
                                                                        > <xsl:value-of select="./@name" />
                                                                      </xsl:otherwise>
                                                                    </xsl:choose>
                                                                  </xsl:otherwise>
                                                                </xsl:choose>
                                                              </xsl:otherwise>
                                                            </xsl:choose>
                                                          </xsl:otherwise>
                                                        </xsl:choose>
                                                      </span>
                                                    </sc:link>
                                                  </xsl:otherwise>
                                                </xsl:choose>


                                              </xsl:element>
                                            </xsl:if>
                                          </xsl:if>
                                        </xsl:for-each>
                                      </ul>
                                    </xsl:if>
                                    <!-- end 4th -->

                                  </xsl:element>
                                </xsl:if>
                              </xsl:if>
                            </xsl:for-each>
                          </ul>
                        </xsl:if>
                      </xsl:element>
                    </xsl:if>
                  </xsl:if>
                </xsl:for-each>
              </ul>
            </xsl:if>
          </xsl:element>
        </xsl:if>
      </xsl:for-each>

    </ul>
  </xsl:template>
</xsl:stylesheet>
